﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;

namespace Kalficom
{
    public class conf
    {
        public static frmMain Main;
        public static int CurUser = 1;
        public static string Server = "LOCALHOST";
        public static string Database = "kalfi_paster";
        public static string CurLanguage = "fr-FR";

        // Query insert into table k_user_log
        public static readonly string Query_User_Log = "INSERT INTO k_user_log(user_id, obj_id, table_id, user_action, log_date) VALUES({0}, {1}, {2}, {3}, GETDATE())";

        //Method set icon to form
        public static void Icon(System.Windows.Forms.Form frm, bool ShowInTaskbar = false)
        {
            frm.Icon =  global :: Kalficom.Properties.Resources.kalficom;
            frm.ShowInTaskbar = ShowInTaskbar;
            frm.BackColor = System.Drawing.Color.White;
            FlushMemory();
        }

        //Reduce the memory usage.
        [DllImport("kernel32.dll")]
        private static extern int SetProcessWorkingSetSize(IntPtr Process, int minimumWorkingSetSize, int MaximumWorkingSetSize);
        private static void FlushMemory()
        {
            //GC.Collect
            //GC.WaitForPendingFinalizers();
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                Process p = Process.GetCurrentProcess();
                SetProcessWorkingSetSize(p.Handle, -1, -1);
                p.Dispose();
            }
        }
    }
}
